package part3;

/**
 * @author wcj
 * @Date 2021/5/11 14:36
 * @Version 1.0
 */
public class Part33 {
    public static void main(String[] args) {

        // 对象数据类型，我们实例化之后操作的是其对象引用，这个时候进行赋值，实际上是将指针指向内存空间的地址
        Brid b1 = new Brid();
        Brid b2 = new Brid();
        b1.speed = 3.15f;
        b2.speed = 2.8f;
        // 3.15,2.8
        System.out.println("b1's speed:" + b1.speed + ",b2's speed:" + b2.speed);
        b1 = b2;
        // 2.8,2.8
        System.out.println("b1's speed:" + b1.speed + ",b2's speed:" + b2.speed);
        b1.speed = 5.9f;
        // 5.9,5.9
        System.out.println("b1's speed:" + b1.speed + ",b2's speed:" + b2.speed);
        f(b1);
        // 3.648,3.648
        System.out.println("b1's speed:" + b1.speed + ",b2's speed:" + b2.speed);


        // 基本数据类型初始化时直接分配了内存空间，执行赋值操作的时候是将一块内存空间的值复制到另一块空间
        int x = 4;
        int y = 8;
        // 4,8
        System.out.println("x=" + x + ",y=" + y);
        x = y;
        // 8,8
        System.out.println("x=" + x + ",y=" + y);
        x = 7;
        // 7,8
        System.out.println("x=" + x + ",y=" + y);
    }

    public static void f(Brid b){
        b.speed = 3.648f;
    }
}

class Brid {
    float speed;
}
